package com.worldstear.core;


import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class DefaultExceptionAdvice {

    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
    public R resolveHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException exception){
        log.error("请求方法不支持 {}", exception.getMessage());
        return R.error(exception.getMessage());
    }

    @ExceptionHandler(AuthenticationException.class)
    public R resolveAuthenticationException(AuthenticationException exception) {
        log.error("请求方法不支持 {}", exception.getMessage());
        return R.error(exception.getMessage());
    }
}
